//
//  CSSectionDetailViewController.m
//  ChinaShip
//
//  Created by Yale on 2019/1/26.
//  Copyright © 2019年 ChinaShip. All rights reserved.
//

#import "CSSectionDetailViewController.h"

@interface CSSectionDetailViewController ()<UIWebViewDelegate>
{
    IBOutlet UIWebView *kWebView;
    IBOutlet NSLayoutConstraint *hLayoutConstraint;
}
@end

@implementation CSSectionDetailViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self hiddenNavBar];
    if (![CSTool getSwitchState]) {
        hLayoutConstraint.constant = 0;
        [self.view layoutIfNeeded];
    }
}

- (IBAction)webBackAction:(id)sender{
    [self popViewController];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    if (@available(ios 11.0,*)) {
        kWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    kWebView.backgroundColor = [UIColor whiteColor];
    kWebView.opaque = NO;
    [self addBackNavbarItem];
    [SVProgressHUD show];
    NSString *requestUrl = [NSString stringWithFormat:@"%@/cssc/api/content/detail.htm?id=%ld",HostPath,self.mid];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]];
    [kWebView loadRequest:request];
    // Do any additional setup after loading the view.
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [SVProgressHUD dismiss];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    [SVProgressHUD dismiss];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [SVProgressHUD dismiss];
}

//跳转登录
- (IBAction)didPushLoginAction:(id)sender{
    if ([CSTool isLogin]) {
        [self pushVcToOtherVc:[[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"CSPurchasingViewController"]];
    }else{
         [self.navigationController presentViewController:[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CSNavigationViewController"] animated:YES completion:nil];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
